﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Custom.Master" CodeBehind="SelectSet.aspx.cs"
    Inherits="Things.Web.OrderPlan.SelectSet" %>

<%@ Register src="../Components/TopSaledList.ascx" tagname="TopSaledList" tagprefix="uc1" %>

<%@ Register src="../Components/GoodsInformation.ascx" tagname="GoodsInformation" tagprefix="uc2" %>

<%@ Register src="../Components/GoodsRelationInformation.ascx" tagname="GoodsRelationInformation" tagprefix="uc3" %>

<%@ Register src="../Components/GoodsInformationForOrderPlan.ascx" tagname="GoodsInformationForOrderPlan" tagprefix="uc4" %>


<%@ Register src="../Components/GoodsRelationInforOP.ascx" tagname="GoodsRelationInforOP" tagprefix="uc6" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script>
        function caculatePrice() {
            var number = parseInt(document.getElementById('_ctlEditNumber').value);
            var cycle = parseInt(document.getElementById('_ctlEditCycle').value);
            var count = parseInt(document.getElementById('_ctlEditCount').value);
            var total = number * cycle;
            var a=<%=GetA() %>;
            var b = <%=GetB() %>;
            var cp = Math.round(<%=GetCB() %>, 2);
            var pm =  Math.round(total * a + b,2);
            var pn = Math.round(<%=GetPN() %>, 2);
            var p= Math.max(pm,pn);
            var tp = Math.round(p * total,2);
            document.getElementById('_totalPrice').innerText = tp;
            document.getElementById('_unitPrice').innerText = p;
            var discount=(p / cp) * 100;
            var index=discount.toString().indexOf(".");
            var strDiscount="10";
            if(index>0)
            {
               strDiscount=discount.toString().substr(0, index);
            }
            else
            {
              strDiscount=discount;
            }
            document.getElementById('_discount').innerText = strDiscount;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table width="973" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
            <td align="center">
                <img src="../style/images/yj1.jpg" width="972" height="15" />
            </td>
        </tr>
    </table>
    <table width="972" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
            <td width="225" align="center" valign="top" bgcolor="#FFFFFF">
                <table width="193" height="29" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="17" bgcolor="#5ED401">
                            &nbsp;
                        </td>
                        <td width="176" align="left" bgcolor="#5ED401" class="td2">
                            消费者保障计划
                        </td>
                    </tr>
                </table>
                <table width="193" height="162" border="0" cellpadding="0" cellspacing="0" class="tdx">
                    <tr>
                        <td width="48" align="center">
                            <img src="../style/images/h.jpg" width="18" height="19" />
                        </td>
                        <td width="145" align="left">
                            送货上门，更省心
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <img src="../style/images/a.jpg" width="18" height="18" />
                        </td>
                        <td align="left">
                            可追溯，更安全
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <img src="../style/images/y.jpg" width="18" height="19" />
                        </td>
                        <td align="left">
                            按月订购，更实惠
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <img src="../style/images/l.jpg" width="18" height="18" />
                        </td>
                        <td align="left">
                            礼品赠送，更健康
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <img src="../style/images/k.jpg" width="18" height="18" />
                        </td>
                        <td align="left">
                            农消对接，更可靠
                        </td>
                    </tr>
                </table>
                <table width="193" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
                <table width="193" height="29" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="17" bgcolor="#5ED401">
                            &nbsp;
                        </td>
                        <td width="176" align="left" bgcolor="#5ED401" class="td2">
                            本周订购排行榜
                        </td>
                    </tr>
                </table>
                <table width="193" height="262" border="0" cellpadding="0" cellspacing="0" class="tdx">
                    <tr>
                        <td align="center" valign="top">
                            
                            <uc1:TopSaledList ID="TopSaledList1" runat="server" />
                            
                        </td>
                    </tr>
                </table>
            </td>
            <td width="747" align="center" valign="top" bgcolor="#FFFFFF">
               <uc4:GoodsInformationForOrderPlan ID="GoodsInformationForOrderPlan1" 
                    runat="server" />
                <table width="747" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td align="center">
                            <asp:Repeater ID="DataList1" runat="server">
                                <ItemTemplate>
                                    <table width="169" border="0" cellpadding="0" cellspacing="0" class="tc<%# Eval("Description") %>">
                                        <tbody>
                                            <tr>
                                                <td height="337" align="center" valign="top">
                                                    <table width="100%" height="117" border="0" cellpadding="0" cellspacing="0">
                                                        <tbody>
                                                            <tr>
                                                                <td>
                                                                    &nbsp;
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <table width="100%" height="160" border="0" cellpadding="0" cellspacing="0">
                                                        <tbody>
                                                            <tr>
                                                                <td width="8%">
                                                                    &nbsp;
                                                                </td>
                                                                <td width="48%" align="right">
                                                                    总价：
                                                                </td>
                                                                <td width="44%" align="left">
                                                                    <%# GetTotalPrice(Eval("UnitPrice"), Eval("DeliveredNumber"), Eval("DeliveredCount"), Eval("DeliveredCycle"))%>元
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>
                                                                    &nbsp;
                                                                </td>
                                                                <td align="right">
                                                                    单价：
                                                                </td>
                                                                <td align="left">
                                                                    <%# Eval("UnitPrice") %>元
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>
                                                                    &nbsp;
                                                                </td>
                                                                <td align="right">
                                                                    折扣：
                                                                </td>
                                                                <td align="left">
                                                                    <%# GetDiscount(Eval("UnitPrice"), Eval("GoodsId"))%>折
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>
                                                                    &nbsp;
                                                                </td>
                                                                <td align="right">
                                                                    送货周期：
                                                                </td>
                                                                <td align="left">
                                                                    1次/<%# Eval("DeliveredCycle") %>个月
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>
                                                                    &nbsp;
                                                                </td>
                                                                <td align="right">
                                                                    送货频率：
                                                                </td>
                                                                <td align="left">
                                                                    <%# Eval("DeliveredCount") %>次
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>
                                                                    &nbsp;
                                                                </td>
                                                                <td align="right">
                                                                    每次数量：
                                                                </td>
                                                                <td align="left">
                                                                    <%# Eval("DeliveredNumber") %>袋
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td>
                                                                    &nbsp;
                                                                </td>
                                                                <td align="right">
                                                                    总商品数量：
                                                                </td>
                                                                <td align="left">
                                                                    <%# GetTotalCount(Eval("DeliveredNumber"), Eval("DeliveredCount"), Eval("DeliveredCycle"))%>袋
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <table width="155" height="40" border="0" cellpadding="0" cellspacing="0">
                                                        <tbody>
                                                            <tr>
                                                                <td height="45" align="center" valign="middle">
                                                                    <a href="<%# "./Ordering.aspx?goodsID="+ Eval("GoodsId") +"&setid="+Eval("Id")%>">
                                                                        <img src="../style/images/ljdg1.jpg" width="82" height="30" border="0" />
                                                                    </a>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </ItemTemplate>
                            </asp:Repeater>
                            <table width="169" border="0" cellpadding="0" cellspacing="0" class="tcD">
                                <tbody>
                                    <tr>
                                        <td height="337" align="center" valign="top">
                                            <table width="99%" height="48" border="0" cellpadding="0" cellspacing="0">
                                                <tbody>
                                                    <tr>
                                                        <td>
                                                            &nbsp;
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            <table width="157" height="157" border="0" cellpadding="0" cellspacing="0">
                                                <tbody>
                                                    <tr>
                                                        <td height="20" align="center">
                                                            1、请选择寄送数量
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="20" align="center">
                                                            每次送<asp:TextBox ID="_ctlEditNumber" ClientIDMode="Static" runat="server" Width="50" onchange="caculatePrice();"></asp:TextBox>盒
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="20" align="center">
                                                            2、请选择寄送频率
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="20" align="center">
                                                            送<asp:TextBox ID="_ctlEditCycle" ClientIDMode="Static" runat="server" Width="50" onchange="caculatePrice();"></asp:TextBox>次
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="20" align="center">
                                                            3、请选择寄送周期
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td height="20" align="center">
                                                            每<asp:TextBox ID="_ctlEditCount" ClientIDMode="Static" runat="server" Width="50" onchange="caculatePrice();"></asp:TextBox>月送一次
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            <table width="97%" height="74" border="0" cellpadding="0" cellspacing="0">
                                                <tbody>
                                                    <tr>
                                                        <td width="8%">
                                                            &nbsp;
                                                        </td>
                                                        <td width="48%" align="right">
                                                            总价：
                                                        </td>
                                                        <td width="44%" align="left">
                                                            <span id="_totalPrice"></span>元
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            &nbsp;
                                                        </td>
                                                        <td align="right">
                                                            单价：
                                                        </td>
                                                        <td align="left">
                                                            <span id="_unitPrice"></span>元
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            &nbsp;
                                                        </td>
                                                        <td align="right">
                                                            折扣：
                                                        </td>
                                                        <td align="left">
                                                            <span id="_discount"></span>折
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            <table width="155" height="40" border="0" cellpadding="0" cellspacing="0">
                                                <tbody>
                                                    <tr>
                                                        <td height="45" align="center" valign="middle">
                                                            <asp:ImageButton ID="ImageButton1" ImageUrl="~/Style/images/ljdg2.jpg" 
                                                                width="82" height="30" runat="server" onclick="ImageButton1_Click" />
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </table>

                <table width="159" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
                
           

                <uc6:GoodsRelationInforOP ID="GoodsRelationInforOP1" runat="server" />

            </td>
        </tr>
    </table>
</asp:Content>
